<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="../includes/importer.jsp"%>
<!doctype html>
<html>

<head>
<ht:head />
<script type="text/javascript">
// -- 关联后台用户
function linkSysUser(id){
		selectLinkUserCallBack(function(userID){
				if(typeof(userID) != 'undefined'){
				$.ajax({
					type: "post",
					url: "./ajaxLinkSysUser?id="+id+"&userId="+userID,
					dataType : "json",
					success: function(data){
						if(data.success == "error"){
							simpleWarn(data.message,null);
						}else{
							if(data.success){
								simpleAlert("关联成功", function() {
									window.location.reload();
				                	});
							}else{
								simpleAlert(data.message,null);
							}
						}
					},
					error: function(){
						simpleWarn('程序异常，请联系管理员解决！',null);
					}
					});
				}
	 		});
	}
	
	function selectLinkUserCallBack(callback,opts){
		var param = $.extend({	
			ShowMessageRow:false,
			Height: 600,
			Width : 800},opts||{});
		
		var url = G_CTX_ROOT + '/store/selectSysUser';
		
		showDialog("关联后台用户",url, function(doc,win){
			var selectRadio = $("input[name='userSelector']:checked",doc);
			if(!jQuery.isEmptyObject(selectRadio)){
				var userID = selectRadio.val();
				if(jQuery.isFunction(callback)){
					callback(userID,doc,win);
				}
			}
		},param);
		}
</script>
</head>
<body>

	<br />
	<div id="search-menu">
		<ul>
			<ht:menu-btn type="search" />
			<ct:display model="store_list" btn="add_btn">
				<ht:menu-btn text="添加商户" url="/store/storeAdd" type="add" />
			</ct:display>
		</ul>
		<br style="clear: left" />
	</div>
	<div class="queryContainer">
		<form name="queryForm" id="queryForm" action="list" method="get">
			<table>
				<tr>
					<td width="100">商户名称：</td>
					<td width="150"><input type="text" name="name"
						value="${param.name}" class="txt" style="width: 150px" /></td>
					<td width="100">商户编号：</td>
					<td width="300"><input id="ordernumber" type="text" name="id"
						value="${param.id}" class="txt validate-number"
						style="width: 100px" />
					<td>区域:</td>
					<td><input type="text" name="areaName"
						value="${param.areaName}" class="txt" /></td>

				</tr>
				<tr>
					<td>审核状态：</td>
					<td><select name="status">
							<option value="">--请选择--</option>
							<c:forEach items="${statusMap }" var="item">
								<option value="${item.key }"
									<c:if test="${param.status == item.key }">selected="selected"</c:if>>${item.value }</option>
							</c:forEach>
					</select></td>
					<td width="70">创建时间：</td>
					<td><input type="text" id="inputStartTime"
						name="inputStartTime" value="${param.inputStartTime}"
						class="txt Wdate" readOnly
						onfocus="WdatePicker({vel:'beginTime',realDateFmt:'yyyyMMdd',maxDate:'#F{$dp.$D(\'inputEndTime\')||\'2050-10-01\'}'})" />
						<input type="hidden" name="beginTime" id="beginTime"
						value="${param.beginTime}" /> 至 <input type="text"
						id="inputEndTime" name="inputEndTime"
						value="${param.inputEndTime}" class="txt Wdate" readOnly
						onfocus="WdatePicker({vel:'endTime',realDateFmt:'yyyyMMdd',minDate:'#F{$dp.$D(\'inputStartTime\')}',maxDate:'2050-10-01'})" />
						<input type="hidden" name="endTime" id="endTime"
						value="${param.endTime}" /></td>
					<td>&nbsp; <ct:btn type="search" />
					</td>
				</tr>
			</table>
		</form>
	</div>
	<div class="container">
		<br />
		<h3>商户列表</h3>
		<div class="mainbox">
			<c:if test="${not empty pageData}">

				<table class="datalist fixwidth">
					<tr>
						<th nowrap="nowrap" width="80">商户编号</th>
						<th nowrap="nowrap" width="150">商户名称</th>
						<th nowrap="nowrap" width="100">区域</th>
						<th nowrap="nowrap" width="70">审核状态</th>
						<th nowrap="nowrap" width="130">创建时间</th>
						<th nowrap="nowrap" width="130">关联后台帐号</th>
						<th nowrap="nowrap">操作</th>
					</tr>
			<c:forEach items="${pageData.data}" var="item">

						<tr>
							<td nowrap="nowrap">${item.id}</td>
							<td nowrap="nowrap" class="ellipsis"><ahref="storeView/${item.id}">${item.name }</a></td>
							<td nowrap="nowrap">${item.areaName}</td>
							<td nowrap="nowrap">${statusMap[item.status] }</td>
							<td nowrap="nowrap">${item.createTime }</td>
							<td nowrap="nowrap">
								<c:if test="${empty item.userName }">未关联</c:if>
								<c:if test="${not empty item.userName }">${item.userName }</c:if>
							</td>
							<td nowrap="nowrap"><ct:display model="store_list" btn="mod_btn">
								<a href="storeEdit?id=${item.id}">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</ct:display> <ct:display model="store_list" btn="del_btn">
									<a href="#this" onclick="deleteItem('storeDel/${item.id}');">删除</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								</ct:display> <c:if test="${item.status == 0 }">
									<ct:display model="store_list" btn="send_audit_btn">
										<a href="#" onclick="dealInfo('确认送审？','audit/${item.id}');">送审</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									</ct:display>
								</c:if>
								<c:if test="${item.status == 3&&empty item.sysUserId}">
									<ct:display model="store_list" btn="link_btn">
										<a href="#" onclick="linkSysUser(${item.id})">关联后台帐号管理</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									</ct:display>
								</c:if>
								<c:if test="${item.status == 3&&empty item.sysUserId}">
									<ct:display model="store_list" btn="">
										<a href="http://121.40.95.55/type/typeList?shop=${item.id }" target="_blank">查看门店商品</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									</ct:display>
								</c:if>
							</td>
						</tr>
					</c:forEach>
				</table>

				<ht:page pageData="${pageData}" />

			</c:if>
			<c:if test="${empty pageData.data}">
				<div class="note">
					<p class="i">目前没有相关记录!</p>
				</div>
			</c:if>
		</div>

	</div>

</body>
</html>